package com.ruoyi.mobile.project.pms.service;

import com.ruoyi.db.pms.domain.PmsGoodsAttribute;
import com.ruoyi.db.pms.domain.query.PmsGoodsAttributeQueryVo;
import com.ruoyi.db.pms.mapper.PmsGoodsAttributeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class WxPmsGoodsAttributeService
{
    @Autowired
    private PmsGoodsAttributeMapper goodsAttributeMapper;

    /**
     *获取商品属性列表
     *
     * @author 张涛
     * @param goodsId
     * @return
     */
    public List<PmsGoodsAttribute> queryByGid(Long goodsId)
    {
        return goodsAttributeMapper.selectPmsGoodsAllAttributeById(goodsId);
    }

    /**
     * 添加商品属性
     *
     * @author 张涛
     * @param goodsAttribute
     */
    public void add(PmsGoodsAttribute goodsAttribute)
    {
        //添加时间
        goodsAttribute.setAddTime(LocalDateTime.now());
        //更新时间
        goodsAttribute.setUpdateTime(LocalDateTime.now());
        //执行添加
        goodsAttributeMapper.insertPmsGoodsAttribute(goodsAttribute);
    }

    public PmsGoodsAttribute findById(Long id)
    {
        return null;
    }

    public void deleteByGid(Long gid)
    {

    }

    /**
     * 删除商品属性
     * @author 张涛
     * @param id
     */
    public void deleteById(Long id)
    {
        goodsAttributeMapper.deletePmsGoodsAttributeById(id);
    }

    /**
     * 修改商品属性
     *
     * @author 张涛
     * @param attribute
     */
    public void updateById(PmsGoodsAttribute attribute)
    {
        attribute.setAddTime(LocalDateTime.now());
        goodsAttributeMapper.updatePmsGoodsAttribute(attribute);
    }
}
